﻿using System.Web.Mvc;
using Glimpse.Core.Extensions;
using Glimpse.Core.Framework;

namespace OrchardGlimpsePOC.Areas.Glimpse.Controllers
{
    public class AssetController : Controller
    {
        public void Index([Bind(Prefix = "n")] string resourceName)
        {
            // HACK: This is a hack for the POC. We will update Glimpse to allow for calling GlimpseRuntime.Instance instead.
            var glimpseRuntime = HttpContext.Application["__GlimpseRuntime"] as GlimpseRuntime;

            if (string.IsNullOrEmpty(resourceName))
                glimpseRuntime.ExecuteDefaultResource();
            else
                glimpseRuntime.ExecuteResource(resourceName, new ResourceParameters(Request.QueryString.ToDictionary()));
        }
    }
}
